package com.bjsxt.chapter19_observer;

/**
 * @ClassName Client
 * @Description 客户端
 * @Author 黑马程序员
 * @Date 15:15 2024/6/25
 * @Version 1.0
 **/
public class Client {
    public static void main(String[] args) {
        // 目标对象
        ConcreteSubject subject = new ConcreteSubject();

        // 创建多个观察者
        ObserverA ob1 = new ObserverA();
        ObserverA ob2 = new ObserverA();
        ObserverA ob3 = new ObserverA();

        // 将这三个观察者添加到subject对象的观察者队伍中
        subject.registerObserver(ob1);
        subject.registerObserver(ob2);
        subject.registerObserver(ob3);

        // 改变subject的状态
        subject.setState(3000);
        System.out.println("**********目标对象修改状态************");
        System.out.println(ob1.getMyState());
        System.out.println(ob2.getMyState());
        System.out.println(ob3.getMyState());

        subject.setState(600);
        System.out.println("**********目标对象修改状态************");
        System.out.println(ob1.getMyState());
        System.out.println(ob2.getMyState());
        System.out.println(ob3.getMyState());

    }
}
